
#include "tools.h"
#include "ecf2m.h"


// 第一部分 A.2.2.2
bool Test_0() {
	bool r = true;

	uint8_t f[] = { 0x25 };
	uint8_t a[] = { 0x01 };
	uint8_t b[] = { 0x01 };

	ECF2mWork ec;
	ECF2m_Initialize(&ec, 8, f, a, b);
	
	{
		ECPoint p1, p2, p12, pp;
		UInteger two;

		UInteger_FromUInt(&p1.x, 0x0a);
		UInteger_FromUInt(&p1.y, 0x18);

		UInteger_FromUInt(&p2.x, 0x08);
		UInteger_FromUInt(&p2.y, 0x1F);

		UInteger_FromUInt(&p12.x, 0x1E);
		UInteger_FromUInt(&p12.y, 0x15);

		UInteger_FromUInt(&pp.x, 0x08);
		UInteger_FromUInt(&pp.y, 0x1F);

		UInteger_FromUInt(&two, 0x02);

		ECPoint v;
		ECF2m_Add(&ec, &p1, &p2, &v);
	
		r = ECPoint_Equal(&p12, &v) && r;

		EC_MUL(&ec, &two, &p1, &v);
		
		r = ECPoint_Equal(&pp, &v) && r;
	}

	return r;
}

bool SM_Test_ECF2m() {
	bool r = true;
	

	r = SM_TEST(Test_0()) && r;
	return r;
}
